import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import zheng.MyApplication;

/**
 * @author: ztl
 * @date: 2025/04/03 23:21
 * @desc:
 */

@SpringBootTest(classes = MyApplication.class)
public class test {

    private RestHighLevelClient client;
    @Test
    public void tes1(){
        System.out.println(12);
    }

    @BeforeAll
    public void test2(){
        // 1. 初始化客户端（确保ES服务已启动）
        client = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost", 9200, "http"))
        );
    }

    @Test
    public void tes3() throws Exception{
        boolean exists = client.indices().exists(
                new GetIndexRequest("indexName"),
                RequestOptions.DEFAULT
        );

        System.out.println(12);
    }
}
